package com.teaching.controller;

import com.teaching.common.ResultObject;
import com.teaching.service.TeachingService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;


/**
 * @author
 * @since
 */
@RestController
@RequestMapping("/teaching")
public class TeachingController {

	@Autowired
    TeachingService teachingService;
	


    @PostMapping("/add")
    public ResultObject add(@RequestBody Map<String, Object> params){
		teachingService.add(params);
    	return ResultObject.isOk();
    }

    @PostMapping("/update")
    public ResultObject update(@RequestBody Map<String, Object> params){
		teachingService.update(params);
    	return ResultObject.isOk();
    }



	@GetMapping("/delete")
    public ResultObject delete(String id){
		teachingService.delete(id);
    	return ResultObject.isOk();
    }


	/**
	 * 列表
	 * @param params
	 * @return
	 */
	@PostMapping("queryList")
	public ResultObject queryList(@RequestBody Map<String, Object> params){
		Map<String, Object> result = teachingService.queryList(params);
		return ResultObject.isOk(result.get("list"),Integer.valueOf(result.get("count").toString()));
	}


    @GetMapping("/queryDetail")
    public ResultObject queryDetail(String id){
    	Map<String, Object> result = teachingService.queryDetail(id);
    	return ResultObject.isOk(result);
    }
	
}
